package com.miaostars.apakey.checks;

import com.miaostars.apakey.Apakey;
import com.miaostars.apakey.utils.PlayerData;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

public class InventoryChecks {
    
    private final Apakey plugin;
    
    public InventoryChecks(Apakey plugin) {
        this.plugin = plugin;
    }
    
    public boolean checkItemDupe(Player player, PlayerData data, ItemStack item) {
        if (!plugin.getConfigManager().getConfig().getBoolean("checks.inventory.enabled")) {
            return false;
        }
        
        if (player.hasPermission("apakey.bypass")) {
            return false;
        }
        
        // Check for impossible item stacks
        if (item != null && item.getAmount() > item.getMaxStackSize()) {
            data.incrementInventoryViolations();
            
            if (data.getInventoryViolations() > plugin.getConfigManager().getConfig().getInt("checks.inventory.max-violations")) {
                return true;
            }
        } else {
            data.decrementInventoryViolations();
        }
        
        return false;
    }
}